<template>
    <!--最大div-->
    <div style="margin-top: -10px">
        <!--新建栏-->
        <div style="border:1px solid #BFBFBF;padding: 10px;background-color: white;margin-top: 10px;height: 40px">
            <el-row :gutter="24">
                <el-col :span="2">
                    <span style="font-size: 18px;line-height:40px;margin-left: 5px">产品管理</span>
                </el-col>
                <el-col :span="7" style="padding-left: 12px;padding-right: 12px;width: 224px;">
                    <el-select v-model="value7" @change="changebusni"  placeholder="选择产品型号">
                        <el-option-group
                                v-for="group in options3"
                                :key="group.label"
                                :label="group.label">
                            <el-option
                                    v-for="item in group.options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-option-group>
                    </el-select>
                    <el-button style="background-color: #F05050;color: white;margin-left: 10px;" @click="cancelseek" icon="el-icon-back" v-show="seek" size="mini" round>解除搜索</el-button>
                </el-col>
                <el-col :span="9">
                    <el-input placeholder="请输入搜索产品的信息" v-model="input" style="width: 250px;">
                        <i slot="suffix" class="el-input__icon el-icon-search" @click="initData"></i>
                    </el-input>
                </el-col>
                <el-col :span="7" style="padding-left: 80px; padding-right: 12px;">
                    <router-link style="line-height:40px;margin-left:200px;" :to="{path:'/qtianjia'}">
                        <el-button size="small"  type="primary" @click="jilutankuan=true">新建产品</el-button>
                    </router-link>
                </el-col>

            </el-row>
        </div>

        <!--表格数据框-->
        <div style="margin-top: 10px;border: 1px solid #BFBFBF;background-color: white">
            <div style="width: 100%;height: 40px;background-color: white;border-bottom: 1px solid #EBEEF5">
                <div class="operate" v-show="cjy">
                    <div class="selected—title" style="border-right: 0px ">
                        产品列表：<span>{{value7}}</span>
                    </div>
                </div>
                <div class="operate" v-show="cje">
                    <div class="selected—title" >
                        已选中<span class="selected—count">{{count}}</span>项
                    </div>
                    <div  class="selected—title1" v-show="isOne">
                        <span><i class="el-icon-edit"></i>修改</span>
                    </div>
                    <div  class="selected—title1">
                        <span><i class="el-icon-delete"></i>删除</span>
                    </div>
                </div>
            </div>
            <el-table
                    :data="proList.slice((pageNum-1)*pageSize,pageNum*pageSize)"
                    style="width: 100%"
                    max-height="450"
                    :default-sort = "{prop: 'date', order: 'descending'}">
                <el-table-column
                        prop="prodetailBh"
                        label="产品编号"
                        align="center">
                </el-table-column>
                <el-table-column
                        label="图片"
                        align="center"
                        prop="picturePath">
                    <template slot-scope="y">
                        <span v-for="pro in y.row.qpictures" :key="pro.prodetailId">
                            {{pro.picturePath}}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="productName"
                        label="产品名称"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="modetId.modetContent"
                        label="产品规格"
                        align="center">
                    <template slot-scope="y">
                        <span v-for="pro in y.row.qmodeldetails" :key="pro.prodetailId">
                            {{pro.modetContent}}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="prodetaiJpri"
                        label="成本价"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="prodetailSpri"
                        label="售价"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="prodetailKcnum"
                        label="库存数量"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="typeId.typeName"
                        label="手机类型"
                        align="center">
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作"
                        align="center"
                        width="100">
                    <template slot-scope="s">
                        <!--如果是三个标签，后两个标签padding-left: 10px;-->
                        <i style="font-size:18px;color: #409EFF" class="el-icon-edit"></i>
                        <i style="font-size:18px;padding-left: 20px;color: #409EFF" class="el-icon-delete" @click="open2(s.row.prodetailId)"></i>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!--分页框-->
        <div style="margin-top: 15px;border: 1px solid #BFBFBF;padding: 10px;background-color: white">
            <div style="text-align: center">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pageNum"
                        :page-sizes="[5, 10, 20, 40]"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="proList.length"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "QProm",
        data() {
            return {
                multipleTable: [],//存放选中值的数组
                isOne:true,//选中项为1就出现添加跟进记录和修改
                //解除搜索是否显示
                seek:false,
                input:'',
                pageSize:5,//页大小
                pageTotal:0,//内容总条数
                pageNum: 1,//当前页
                //下拉选择框
                options3: [{
                    label: '热门城市',
                    options: [{
                        value: '上海',
                        label: '上海'
                    }, {
                        value: '北京测试',
                        label: '北京'
                    }]
                }, {
                    label: '城市名',
                    options: [{
                        value: '成都成都',
                        label: '成都'
                    }, {
                        value: '深圳深圳',
                        label: '深圳'
                    }, {
                        value: '广州广州',
                        label: '广州'
                    }, {
                        value: '大连大连',
                        label: '大连'
                    }]
                }],
                value7: '',
                //场景一
                cjy:true,
                //场景二
                cje:false,
                //搜索框
                input23: '',
                //表格
                proList: [],
            }
        },
        methods: {
            //前端分页
            handleSizeChange: function (size) {
                this.pageSize = size;
                console.log(this.pageSize)  //每页下拉显示数据
            },
            handleCurrentChange: function(currentPage){
                this.pageNum = currentPage;
                console.log(this.pageNum)  //点击第几页
            },
            /*跳转详情方法*/
            todetails(rows){
                this.$router.push({
                    path:'/zhuye/qprom/qspxx',
                    query: {
                        row:rows
                    }

                })
            },
            //前端分页查询
            initData(){
                window.console.log();
                this.$axios.post("http://localhost:8088/pur/chanping-list",this.qs.stringify({
                    input:this.input}))
                    .then(v=>{
                        this.proList = v.data;
                    })
                    .catch()
            },
            /*新建产品方法*/
            showmian(){

            },
            /*表格删除方法*/
            open2(id){
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$axios.post("http://localhost:8088/pur/delete-chanp",this.qs.stringify(
                        {id:id}))
                        .then(()=>{
                            this.initData();
                            this.$notify({
                                title:'成功',
                                type: 'success',
                                message: '删除成功!'
                            });
                        }).catch(v=>{
                        alert("加载失败删除："+v.data);
                    })
                }).catch(() => {
                    this.$notify({
                        title:'取消',
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            /*选择类型商机方法*/
            changebusni(){
                if(this.value7!=''){
                    this.seek=true;
                }
            },
            /*解除选择类型商机方法*/
            cancelseek(){
                this.value7='';
                this.seek=false;
            }
        },
        computed:{
            count(){
                return this.multipleTable.length
            },
        },
        created:function() {
            this.initData();
        }


    }
</script>

<style scoped>

    .addview:hover{
        color: white;
    }
    a{
        text-decoration: none;
        color: #409EFF;
    }
    a:hover{
        color: white;
    }
    .busin:hover{
        color: #3E84E9;
        cursor:pointer;
    }
    .businame{
        color: #606266;
    }
    .businame:hover{
        color: #409EFF;
        cursor:pointer;
    }
    .operate{
        font-size: 12px;
        height: 40px;
        padding: 0 20px;
        color: #777;
        background: white;
    }
    .selected—title{
        margin-top: 15px;
        margin-left: -6px;
        border-right: 1px solid #e6e6e6;
        width: 86px;
        height:20px;
        float: left;
    }
    .selected—title1{
        margin-top: 15px;
        border-right: 1px solid #e6e6e6;
        width: 86px;
        height:20px;
        float: left;
        cursor: pointer;
    }

    .selected—title1 span{
        margin-left: 24px;
    }
    .selected—title1 span:hover{
        color:#409eff;
    }
    .selected—title2{
        margin-top: 15px;
        border-right: 1px solid #e6e6e6;
        width: 129px;
        height:20px;
        float: left;
        cursor: pointer;
    }

    .selected—title2 span{
        margin-left: 24px;
    }
    .selected—title2 span:hover{
        color:#409eff;
    }
</style>